/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jgaptest;

import org.jgap.Configuration;
import org.jgap.DefaultFitnessEvaluator;
import org.jgap.InvalidConfigurationException;
import org.jgap.event.EventManager;
import org.jgap.impl.*;
import org.jgap.util.ICloneable;

/**
 *
 * @author jkanazawa
 */
public class ConfiguracionAG extends Configuration implements ICloneable {
    final int m_tournament_size = 2;
    final double m_probability = 0.7d;
    final double m_crossover_probability = 0.97d;
    final int m_mutation_ratio = 30;
    final double m_no_reproduction_probability = 0.9d;
    
    public ConfiguracionAG(String a_id, String a_name) {
        super(a_id, a_name);
        try {
            setBreeder(new GABreeder());
            setRandomGenerator(new StockRandomGenerator());
            setEventManager(new EventManager());
            TournamentSelector tournamentSelector = new TournamentSelector(this, m_tournament_size, m_probability);
            addNaturalSelector(tournamentSelector, false);
            setMinimumPopSizePercent(0);
            setSelectFromPrevGen(m_no_reproduction_probability);
            setKeepPopulationSizeConstant(true);
            
            setFitnessEvaluator(new DefaultFitnessEvaluator());
            setChromosomePool(new ChromosomePool());
            addGeneticOperator(new CrossoverOperator(this, m_crossover_probability));
            addGeneticOperator(new MutationOperator(this, m_mutation_ratio));
        } catch (InvalidConfigurationException e) {
            throw new RuntimeException(
                    "Fatal error: DefaultConfiguration class could not use its "
                    + "own stock configuration values. This should never happen. "
                    + "Please report this as a bug to the JGAP team.");
        }
    }

    public ConfiguracionAG() {
        this("", "");
    }

    @Override
    public Object clone() {
        return super.clone();
    }
}
